﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame3
{
    class Drawable
    {
        public Vector2 pos;
        public Texture2D tex;
        public Rectangle col;
        public Drawable(){}
        public Drawable(float a, float b, Texture2D c)
        {
            pos.X = a;
            pos.Y = b;
            tex = c;
            col = new Rectangle((int)a, (int)b, c.Width, c.Height);
        }
    }
    class Movable : Drawable
    {
        public int i, j;
        public void move(float a,float b)
        {
            pos.X+=a;
            pos.Y+=b;
        }
    }

    class Weapon
    {
    }

    
    class Character : AnimatedSprite
    {
        protected float life;
        protected Weapon weaponA;
        protected Weapon weaponB;

        public Character(float d,float e,Texture2D f,float a,Weapon b ,Weapon c)
        {
            rows = 4;
            column = 10;
            currentFrame = 0;
            currentRow = 0;
            totalFrames = 40;
            pos.X = d;
            pos.Y = e;
            tex=f;
            life=a;
            weaponA=b;
            weaponB=c;
        }
        public void Update()
        {
            currentFrame++;
            if (currentFrame == ((currentRow+1)*10))
                currentFrame = currentRow*10;
            currentRow = (int)((float)currentFrame / (float)column);
        }
        public void Draw(SpriteBatch spriteBatch, Vector2 location)
        {
            int width = tex.Width / column;
            int height = tex.Height / rows;
            int currentColumn = currentFrame % 10;

            Rectangle sourceRectangle = new Rectangle(width * currentColumn, height * currentRow, width, height);
            Rectangle destinationRectangle = new Rectangle((int)location.X, (int)location.Y, width, height);

            spriteBatch.Begin();
            spriteBatch.Draw(tex, destinationRectangle, sourceRectangle, new Color(new Vector4(1, 0, 0, 1)));
            spriteBatch.End();
        }
    }
    class AnimatedSprite : Movable
    {
        public int rows;
        public int column;
        public int currentFrame;
        public int totalFrames;
        public int currentRow;

    }

}


